package com.sgb.goods.api;

import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.dialog.DialogHelper;

import org.jetbrains.annotations.NotNull;

import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public abstract class NetCallBack<T> implements Callback<T> {

    public abstract void onSuccess(T data);

    @Override
    public void onResponse(@NotNull Call<T> call, @NotNull Response<T> response) {
        // 网络请求成功 200..300
        if(response.isSuccessful()) {
            onSuccess(response.body());
        } else {
            // 网络请求失败 500、404等
        }
        onFinally();
    }

    @Override
    public void onFailure(@NotNull Call<T> call, Throwable t) {
        onFinally();
    }

    public void onFinally() {

    }
}
